﻿
using MassTransit;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
namespace Athena.Observer
{
    public class DefaultConnectSendObserver : BaseObserver<DefaultConnectSendObserver>, ISendObserver
    {
        public DefaultConnectSendObserver(ILogger logger) : base(logger)
        {

        }


        /// <summary>
        /// // called just before a message is sent, all the headers should be setup and everything
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual Task PreSend<T>(SendContext<T> context)
       where T : class
        {
            return Task.CompletedTask;
        }

        /// <summary>
        /// // called just after a message it sent to the transport and acknowledged (RabbitMQ)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual Task PostSend<T>(SendContext<T> context)
            where T : class
        {
            return Task.CompletedTask;
        }

        /// <summary>
        /// // called if an exception occurred sending the message
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <param name="exception"></param>
        /// <returns></returns>
        public virtual Task SendFault<T>(SendContext<T> context, Exception exception)
            where T : class
        {
            return Task.CompletedTask;
        }


    }
}
